Bar codes employ a pattern of bar elements and space elements of varying widths to represent data. Some systems for reading barcodes use a CCD imager to take a picture of the barcode and analyze the image data to locate and decode the barcode. Once the location and orientation of a bar code is determined within an image, it is necessary to obtain the gray scale profile across the bar code. This profile is needed to calculate the size of the bar elements and space elements to decode the data represented by the bar code. Proper bar and space element width measurements are crucial to correctly reading bar codes. Typically, a scan line is projected across the bar code from one end to the other. This scan line can be at any orientation from 0°–360° due to the orientation of the bar code itself. In order to calculate the width of the bar and space elements it is necessary to obtain the grayscale values of the pixels that lie on the scan line. As long as the scan line is at a constant angle, the ratio of the different width bar code elements will be constant so the correct data can eventually be extracted. However, if the angle of the scan line changes within the bar code, the apparent widths of the elements will change too: the ratio of the widths will not be constant and errors will result. The angle of the scan line can change because the scan line must change direction in order to avoid mutilated or obscured bar code portions or when a chain code or other pixel to pixel scan path technique is employed to simulate the scan lines at some angle where the scan line is actually made up of a combination of one or more scan paths of different angles. In these instances the apparent width of a bar code element can vary depending upon the angle of the scan path along which it was scanned. In this case, the ratio will not be constant and errors will result. Chain codes are explained in Digital Image Processing, Second Edition, Gonzalez, Rafael C. and Wintz, Paul, pp. 392–394.